package com.ruoyi.statistic.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.statistic.domain.TMonthSalaryBillInfo;
import com.ruoyi.statistic.service.ITMonthSalaryBillInfoService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 月工资表Controller
 * 
 * @author ruoyi
 * @date 2024-12-31 08:43:25
 */
@RestController
@RequestMapping("/statistic/monthsalary")
public class TMonthSalaryBillInfoController extends BaseController
{
    @Autowired
    private ITMonthSalaryBillInfoService tMonthSalaryBillInfoService;

    /**
     * 查询月工资表列表
     */
    @PreAuthorize("@ss.hasPermi('statistic:monthsalary:list')")
    @GetMapping("/list")
    public TableDataInfo list(TMonthSalaryBillInfo tMonthSalaryBillInfo)
    {
        startPage();
        List<TMonthSalaryBillInfo> list = tMonthSalaryBillInfoService.selectTMonthSalaryBillInfoList(tMonthSalaryBillInfo);
        return getDataTable(list);
    }

    /**
     * 导出月工资表列表
     */
    @PreAuthorize("@ss.hasPermi('statistic:monthsalary:export')")
    @Log(title = "月工资表", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TMonthSalaryBillInfo tMonthSalaryBillInfo)
    {
        List<TMonthSalaryBillInfo> list = tMonthSalaryBillInfoService.selectTMonthSalaryBillInfoList(tMonthSalaryBillInfo);
        ExcelUtil<TMonthSalaryBillInfo> util = new ExcelUtil<TMonthSalaryBillInfo>(TMonthSalaryBillInfo.class);
        util.hideColumn("company", "vehicleMark", "freightNumber", "transportLocation", "basicSalary"
            ,"tripNumber", "freightWeight");
        util.exportExcel(response, list, "月工资表数据");
    }

    /**
     * 获取月工资表详细信息
     */
    @PreAuthorize("@ss.hasPermi('statistic:monthsalary:query')")
    @GetMapping(value = "/{salaryBillId}")
    public AjaxResult getInfo(@PathVariable("salaryBillId") Long salaryBillId)
    {
        return success(tMonthSalaryBillInfoService.selectTMonthSalaryBillInfoBySalaryBillId(salaryBillId));
    }

    /**
     * 新增月工资表
     */
    @PreAuthorize("@ss.hasPermi('statistic:monthsalary:add')")
    @Log(title = "月工资表", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TMonthSalaryBillInfo tMonthSalaryBillInfo)
    {
        tMonthSalaryBillInfo.setCreateBy(getNickName());
        return toAjax(tMonthSalaryBillInfoService.insertTMonthSalaryBillInfo(tMonthSalaryBillInfo));
    }

    /**
     * 修改月工资表
     */
    @PreAuthorize("@ss.hasPermi('statistic:monthsalary:edit')")
    @Log(title = "月工资表", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TMonthSalaryBillInfo tMonthSalaryBillInfo)
    {
        tMonthSalaryBillInfo.setUpdateBy(getNickName());
        return toAjax(tMonthSalaryBillInfoService.updateTMonthSalaryBillInfo(tMonthSalaryBillInfo));
    }

    /**
     * 删除月工资表
     */
    @PreAuthorize("@ss.hasPermi('statistic:monthsalary:remove')")
    @Log(title = "月工资表", businessType = BusinessType.DELETE)
	@DeleteMapping("/{salaryBillIds}")
    public AjaxResult remove(@PathVariable Long[] salaryBillIds)
    {
        return toAjax(tMonthSalaryBillInfoService.deleteTMonthSalaryBillInfoBySalaryBillIds(salaryBillIds));
    }
}
